#include "ReadFlynns.h"

/*! @brief A condtructor.
 * @param ifName this pointer receive a string(file name) forwared from a produced instance.
 * 
 * this constructor receive a input file name as a parameter(string type pointer) from a instance 
 * and forward the parameter to a member-data(string type pointer) during initiation.
 */
CReadFlynns::CReadFlynns(char *ifName)
{
	fName=ifName;
}

/*! @brief A destructor.
 */ 
CReadFlynns::~CReadFlynns()
{
}

/*! @brief A member function for reading an input file.
 * 
 * Function for reading node-values of each flynn in the input file.
 */
int CReadFlynns::ReadFile()
{
	ifstream ElleFile;				//file handler.			
	ElleFile.open(fName);
	
	ElleFile>>readBuffer;
	while (!ElleFile.eof())
	{
		if (readBuffer=="FLYNNS")
		{
			cout<<readBuffer<<endl;
			
			ElleFile>>readBuffer;
			while ((readBuffer!="OPTIONS")
				&&(readBuffer!="F_ATTRIB_A")
				&&(readBuffer!="LOCATION")
				&&(ElleFile!=NULL))
			{	
				cout<<"Flynn number: "<<readBuffer<<endl;
				//
				getline(ElleFile, readBuffer);
				istringstream flynnNum(readBuffer);
				int temp;
				while (!flynnNum.eof())
				{
					flynnNum>>temp;
					cout<<temp<<" ";
				}
				cout<<endl;

				ElleFile>>readBuffer;
			}
		}
		ElleFile>>readBuffer;
	}
	
	ElleFile.close();
	return 0;
}
